(use-modules
 ;; ftw stands for file-tree-walk
 ;; for file-system-tree
 (ice-9 ftw)
 ;; for match-lambda
 (ice-9 match))


;; from:
;; https://www.gnu.org/software/guile/manual/html_node/File-Tree-Walk.html
(define remove-stat
  ;; Remove the `stat' object the `file-system-tree' provides
  ;; for each file in the tree.
  (match-lambda
    ((name stat)              ; flat file
     name)
    ((name stat children ...) ; directory
     (list name (map remove-stat children)))))


(define list-dir
  (λ (path-to-dir)
    (remove-stat (file-system-tree path-to-dir))))


(display
 (simple-format
  #f "~a\n"
  (list-dir ".")))
